package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCarMapper {
    /**
     * 条件查询购物车是否有无商品
     *
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> selectlist(ShoppingCart shoppingCart);

    /**
     * 更新商品数量
     *
     * @param shoppingCart
     */
    @Update("UPDATE shopping_cart set number=#{number} where id=#{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     * 新增商品数量
     *
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart (name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time) " +
            " values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    @Select("SELECT *from  shopping_cart where user_id=#{userId}")
    List<ShoppingCart> select(Long currentId);
@Delete("DELETE from shopping_cart where user_id=#{userId}")
    void delete(Long currentId);

    @Delete("DELETE  from  shopping_cart where id=#{id}")
    void deleteby(Long id);

    void insertBartch(ShoppingCart shoppingCart);
}
